Simplify _WT_ROOT to a constant defaulting to ~/.wt#17
Merged
guodong-sq merged 4 commits intomainfrom Feb 13, 2026
Merged
Conversation
Replace the fragile _WT_SCRIPT_PATH detection and _wt_resolve_root resolution with a simple constant. The previous approach was susceptible to multiple shell-specific issues (zsh $0 returning "-zsh", zsh command cd not changing subshell directory) that caused _WT_ROOT to resolve to the shell's startup cwd. Since install.sh always installs to ~/.wt/, hardcoding the default is both simpler and more reliable. _WT_ROOT can still be overridden before sourcing for development use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_WT_SCRIPT_PATHdetection +_wt_resolve_rootresolution with a simple constant:_WT_ROOT="${_WT_ROOT:-$HOME/.wt}"$0returning-zshwhenFUNCTION_ARGZEROis unset (Fix _WT_ROOT resolution and make install.sh context setup optional #16)command cdrunning external/usr/bin/cdwhich can't change the subshell directory (fix(zsh): use builtin cd instead of command cd in _wt_resolve_root #15)cd(fix(setup): prevent clobberedcdrelated issues e.g. Zoxide #8)$HOME/.wtfallback in_wt_source_lib(no longer needed since_WT_ROOTis always correct)_WT_ROOTcan be overridden before sourcing for development:_WT_ROOT=/path/to/checkout source /path/to/checkout/wt.sh_WT_ROOTandINSTALL_DIRstay in syncSupersedes #15.
Test plan
echo "$_WT_ROOT"shows~/.wtwt switch,wt list, etc. — confirm all commands work_WT_ROOT=$PWD source ./wt.sh && echo "$_WT_ROOT"